package com.szrt.java.day20161230.demo02;

public class Student02 {
	
	
	private int age;
	
	private char sex;
	
	private String name;
	
	
	

	public String getName() {
		return name;
	}

	
	/**
	 * 一个类如果没有调用它的构造方法  null
	 * @param name
	 */
	public void setName(String name) {
		if(name != null){
			int len = name.length();
			if(len>=2 && len <=4){
				this.name = name;
			}
		}
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		if(age>=1 && age<=130){
			this.age = age;
		}
	}

	public char getSex() {
		return sex;
	}

	public void setSex(char sex) {
		if(sex == '男' || sex == '女' ){
			this.sex = sex;
		}
	}


	@Override
	public String toString() {
		return "Student02 [age=" + age + ", sex=" + sex + ", name=" + name + "]";
	}

	

	
	
	
	
	
	
	

}
